//
//  LearnSkillBottomCell.m
//  ShangHaiTuJI
//
//  Created by xiaoxiangtuji on 2017/7/21.
//  Copyright © 2017年 xiaoxiangtuji. All rights reserved.
//

#import "LearnSkillBottomCell.h"
#import "OpusListModel.h"

@implementation LearnSkillBottomCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
-(void)setModel:(OpusListModel *)model{
    _model = model;
    UILabel *firstlabel = [[UILabel alloc] init];
    firstlabel.text = _model.authorName;
    [self.contentView addSubview:firstlabel];
    [firstlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right);
        make.left.equalTo(self.contentView.mas_left);
        make.top.equalTo(self.contentView.mas_top);
        make.height.mas_equalTo(cellScaleTopAndBottom(20));
    }];
    UILabel *secondlabel = [[UILabel alloc] init];
    secondlabel.text = _model.authorTitle;
    [self.contentView addSubview:secondlabel];
    [secondlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right);
        make.left.equalTo(self.contentView.mas_left);
        make.top.equalTo(firstlabel.mas_bottom);
        make.height.mas_equalTo(cellScaleTopAndBottom(20));
    }];
    UIImageView *bgImageView = [[UIImageView alloc] init];
    bgImageView.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:bgImageView];
    [bgImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",PictureIp,_model.imagepath]] placeholderImage:[UIImage imageNamed:@""]];
    [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right);
        make.left.equalTo(self.contentView.mas_left);
        make.top.equalTo(secondlabel.mas_bottom);
        make.height.mas_equalTo(cellScaleTopAndBottom(150));
    }];
    UILabel *videotitleLabel = [[UILabel alloc] init];
    videotitleLabel.text = _model.name;
    [self.contentView addSubview:videotitleLabel];
    [videotitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right);
        make.left.equalTo(self.contentView.mas_left);
        make.top.equalTo(bgImageView.mas_bottom);
        make.height.mas_equalTo(cellScaleTopAndBottom(20));
    }];
    UIImageView *watchImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:watchImageView];
    [watchImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left);
        make.width.mas_equalTo(cellScaleLeftAndRight(30));
        make.top.equalTo(videotitleLabel.mas_bottom).offset(cellScaleTopAndBottom(10));
        make.height.mas_equalTo(cellScaleTopAndBottom(30));
    }];
    UILabel *videowatchLabel = [[UILabel alloc] init];
    videowatchLabel.text = _model.count;
    [self.contentView addSubview:videowatchLabel];
    [videowatchLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(watchImageView.mas_right).offset(cellScaleLeftAndRight(5));
        make.top.equalTo(videotitleLabel.mas_bottom).offset(cellScaleTopAndBottom(10));
        make.height.mas_equalTo(cellScaleTopAndBottom(30));
        make.width.mas_equalTo(cellScaleLeftAndRight(120));
    }];
    UIButton *shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.contentView addSubview:shareBtn];
    UIButton *collectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.contentView addSubview:collectBtn];
    [shareBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(videotitleLabel.mas_bottom).offset(cellScaleTopAndBottom(10));
        make.left.equalTo(videowatchLabel.mas_right).offset(cellScaleLeftAndRight(120));
        make.height.mas_equalTo(cellScaleTopAndBottom(30));
        
    }];
    [collectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(videotitleLabel.mas_bottom).offset(cellScaleTopAndBottom(10));
        make.left.equalTo(shareBtn.mas_right).offset(cellScaleLeftAndRight(20));
        make.height.mas_equalTo(cellScaleTopAndBottom(30));
        make.width.mas_equalTo(shareBtn.mas_width);
        make.right.equalTo(self.mas_right).offset(cellScaleLeftAndRight(-10));
    }];
    shareBtn.backgroundColor = [UIColor redColor];
    collectBtn.backgroundColor = [UIColor greenColor];
    

}
@end
